home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Slider 1.0 / Sources / UGrayscaleAppearance.h < prev   
Encoding:
Text File  |  1996-06-19  |  3.5 KB  |  103 lines  |  [TEXT/CWIE]

  1. //
  2. //    UGrayscaleAppearance.h
  3. //
  4. //    Utilities for supporting the Apple Grayscale Appearance for System 7.5
  5. //
  6. //    Note: The Attachments can't paint to the edges of dialogs.
  7. //    For dialogs, use ResEdit to set the Content Color of the WIND's wctb 
  8. //    to ga_Background = { 56797, 56797, 56797 }
  9. //
  10. //    Note: Most references to ga_2 or ga_Background might be ignored since
  11. //    the background will usually have been erased.
  12. // 
  13. //
  14. //    Copyright © 1996 by James Jennings. All rights reserved.
  15. //
  16.  
  17. #pragma once
  18.  
  19. class UGrayscaleAppearance {
  20.     // really just a namespace for our basic utilities.
  21. public:
  22.     typedef enum {
  23.             ga_White     = 0xF,
  24.             ga_1        = 0xE,
  25.             ga_2        = 0xD,
  26.             ga_3        = 0xC,
  27.             ga_4        = 0xB,
  28.             ga_5        = 0xA,
  29.             ga_6        = 0x9,
  30.             ga_7        = 0x8,
  31.             ga_8        = 0x7,
  32.             ga_9        = 0x6,
  33.             ga_10        = 0x5,
  34.             ga_11        = 0x4,
  35.             ga_12        = 0x2,
  36.             ga_Black    = 0x0,
  37.             ga_Hilite    = ga_White,
  38.             ga_Background = ga_2,
  39.             ga_Shadow    = ga_6
  40.             } EGAColor;
  41.     static void        GetColor( EGAColor in, RGBColor & out )
  42.                     { out.red = out.green = out.blue = in * 0x1111; }
  43.     static void        SetForeColor( EGAColor in )
  44.                     { RGBColor c; GetColor( in, c ); ::RGBForeColor( &c ); }
  45.     static void        SetBackColor( EGAColor in )
  46.                     { RGBColor c; GetColor( in, c ); ::RGBBackColor( &c ); }
  47.     
  48.     static void        PaintRect( Rect &inFrame, EGAColor inFill )
  49.                     { SetForeColor( inFill ); ::PaintRect( &inFrame ); }
  50.     static void        EraseRect( Rect &inFrame, EGAColor inFill = ga_Background )
  51.                     { SetBackColor( inFill ); ::EraseRect( &inFrame ); }
  52.     static void        FrameRect( const Rect &inFrame, 
  53.                         EGAColor inTopLeft, EGAColor inBottomRight, EGAColor inCorners);
  54.     
  55.     static void        PrimaryGroupRect( Rect inFrame, EGAColor inTopLeft, EGAColor inBottomRight );
  56.     
  57.     static void        PrimaryActiveGroupRect( const Rect &inFrame )
  58.                         { PrimaryGroupRect( inFrame, ga_7, ga_White ); }
  59.     static void        PrimaryInactiveGroupRect( const Rect &inFrame )    // note: text should be ga_7
  60.                         { PrimaryGroupRect( inFrame, ga_4, ga_1 ); }
  61.     static void        SecondaryActiveGroupRect( const Rect &inFrame )
  62.                         { FrameRect( inFrame, ga_7, ga_White, ga_Background ); }
  63.     static void        SecondaryInactiveGroupRect( const Rect &inFrame )// note: text should be ga_7
  64.                         { FrameRect( inFrame, ga_4, ga_1, ga_Background ); }
  65. };
  66.  
  67. // A base class for all Grayscale Appearance attachments.
  68. // ExecuteSelf() determines the kind of device, and calls one of the Draw... methods.
  69. // Sub-classes override the draw methods.
  70. class CGABaseAttachment : public LAttachment, public UGrayscaleAppearance {
  71. protected:
  72.     CGABaseAttachment() : LAttachment( msg_DrawOrPrint ) {}
  73. public:
  74.     virtual void    ExecuteSelf(
  75.                             MessageT        inMessage,
  76.                             void            *ioParam);
  77.     virtual void    DrawColor( Rect &inFrame ) {}
  78.     virtual void    DrawBlackAndWhite( Rect &inFrame ) {}
  79. protected:
  80.     virtual void    AdjustClipRect( Rect &inRect ) { ::InsetRect( &inRect, -1, -1 ); }    
  81. };
  82.  
  83. // An attachment that adds a Grayscale Appearance to a basic pane.
  84. // (Background fill, convex bevel)
  85. class CGAPaneAttachment : public CGABaseAttachment {
  86. public:
  87.     virtual void    DrawColor( Rect &inFrame );
  88. };
  89.  
  90. // An attachment that adds the Grayscale Appearance of a movable modal dialog box.
  91. // (Background fill, 2 pixel convex bevel, no black outline)
  92. class CGADeepPaneAttachment : public CGABaseAttachment {
  93. public:
  94.     virtual void    DrawColor( Rect &inFrame );
  95. };
  96.  
  97. // An attachment that adds a Grayscale Appearance to things like LEditField.
  98. // (No fill, concave bevel)
  99. class CGATextFieldAttachment : public CGABaseAttachment {
  100. public:
  101.     virtual void    DrawColor( Rect &inFrame );
  102. };
  103.